home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / Clueless.swf / scripts / PowerupAddTime.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  3.4 KB  |  98 lines

  1. package
  2. {
  3.    import Common.SoundManager;
  4.    import Forms.DressupForm;
  5.    import flash.utils.setTimeout;
  6.    import org.flintparticles.actions.Accelerate;
  7.    import org.flintparticles.actions.Age;
  8.    import org.flintparticles.actions.Fade;
  9.    import org.flintparticles.actions.Move;
  10.    import org.flintparticles.counters.Blast;
  11.    import org.flintparticles.emitters.Emitter;
  12.    import org.flintparticles.initializers.ImageClasses;
  13.    import org.flintparticles.initializers.Lifetime;
  14.    import org.flintparticles.initializers.Position;
  15.    import org.flintparticles.initializers.Velocity;
  16.    import org.flintparticles.renderers.DisplayObjectRenderer;
  17.    import org.flintparticles.zones.MultiZone;
  18.    import org.flintparticles.zones.RectangleZone;
  19.    
  20.    public class PowerupAddTime extends Powerup
  21.    {
  22.        
  23.       
  24.       protected const NUM_PARTICLES:int = 100;
  25.       
  26.       internal var _dressupform:DressupForm;
  27.       
  28.       internal var _renderer:DisplayObjectRenderer;
  29.       
  30.       protected const PARTICLE_SPEED:int = 25;
  31.       
  32.       internal var _emitter:Emitter;
  33.       
  34.       protected const ZONE_WIDTH:int = 50;
  35.       
  36.       public function PowerupAddTime()
  37.       {
  38.          super();
  39.          _sName = "add time";
  40.          _sDescription = "Gives additional time";
  41.       }
  42.       
  43.       override public function spawn() : Powerup
  44.       {
  45.          return new PowerupAddTime();
  46.       }
  47.       
  48.       protected function eraseEffect() : void
  49.       {
  50.          _emitter.pause();
  51.          _dressupform.removeChild(_renderer);
  52.          _emitter = null;
  53.          _renderer = null;
  54.       }
  55.       
  56.       override public function activate(param1:Array, param2:Array, param3:DressupForm, param4:DressupLevelInfo) : void
  57.       {
  58.          var _loc5_:MultiZone = null;
  59.          var _loc6_:DressupModel = null;
  60.          var _loc7_:Number = NaN;
  61.          var _loc8_:Number = NaN;
  62.          var _loc9_:Number = NaN;
  63.          var _loc10_:Number = NaN;
  64.          super.activate(param1,param2,param3,param4);
  65.          SoundManager.getInstance().playSound("PowerupTimeSound");
  66.          param3.addTime(param4.MillisecondsAllowed / 2);
  67.          _emitter = new Emitter();
  68.          _emitter.counter = new Blast(NUM_PARTICLES);
  69.          _emitter.addInitializer(new ImageClasses([KintabLarge,KintabSmall]));
  70.          _emitter.addInitializer(new Lifetime(0.1,3));
  71.          _emitter.addAction(new Age());
  72.          _emitter.addAction(new Fade());
  73.          _loc5_ = new MultiZone();
  74.          for each(_loc6_ in param2)
  75.          {
  76.             _loc7_ = Number(_loc6_.ModelTimerBar.x);
  77.             _loc8_ = _loc6_.ModelTimerBar.y;
  78.             _loc9_ = _loc6_.ModelTimerBar.width;
  79.             _loc10_ = _loc6_.ModelTimerBar.height;
  80.             if(_loc6_.visible)
  81.             {
  82.                _loc5_.addZone(new RectangleZone(_loc7_,_loc8_,_loc7_ + _loc9_,_loc8_ + _loc10_));
  83.             }
  84.          }
  85.          _emitter.addInitializer(new Position(_loc5_));
  86.          _emitter.addInitializer(new Velocity(new RectangleZone(-PARTICLE_SPEED,-PARTICLE_SPEED,0,0)));
  87.          _emitter.addAction(new Accelerate(0,-30));
  88.          _emitter.addAction(new Move());
  89.          _renderer = new DisplayObjectRenderer();
  90.          _emitter.renderer = _renderer;
  91.          _dressupform = param3;
  92.          param3.addChild(_renderer);
  93.          _emitter.start();
  94.          setTimeout(eraseEffect,3000);
  95.       }
  96.    }
  97. }
  98.